package com.example.myservice_provider.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.myservice_provider.entity.Comment;
import com.example.myservice_provider.entity.Response;
import com.example.myservice_provider.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/comment")
public class Commentcontroller {

    @Autowired
    private PostService postService;

    @PostMapping(value = {"/addComment"})
    public Response addcomemt(@RequestBody Comment comment) throws  Exception{
        Response response =new Response();

        response.setHead("OK");
        response.setCode(this.postService.addCommon(comment));
        return response;
    }
    @PostMapping(value = {"/getComment"})
    public Response getcomemt(Integer postID,Integer page) throws  Exception{
        Response response =new Response();
        response.setHead("OK");
        response.setCode(1);
        response.setData(this.postService.getCommon(page, postID));
        return response;
    }
    @PostMapping(value = {"/starComment"})
    public Response starcomemt(Integer comID) throws  Exception{
        Response response =new Response();

        response.setHead("OK");
        response.setCode(this.postService.starCommon(comID));
        return response;
    }
}
